#!/bin/bash

# input file list using STDIN
total_size=0;
total_num=0;
for i in `cat $1`
do
  if [ -f $i ]; then
    size_info=`du -sS $i`
    size=`echo $size_info | cut -d " " -f 1`
    total_size=`expr $total_size + $size`
    total_num=`expr $total_num + 1`
  fi
done

# OUTPUT
echo "total file: $total_num"
echo "total size(K): ${total_size}K"
mega_size=`echo "scale=2; ${total_size}/1024" | bc`
echo "total size(M): ${mega_size}M"
giga_size=`echo "scale=2; $total_size/(1024*1024)" | bc`
echo "total size(G): ${giga_size}G"
